The general idea is that if you know the net force on a particle and its initial position and velocity, then you can calculate its velocity and position at a later time by integrating Newton's second law. It's common to express Newton's second law as a differential equation.
$$\frac{d^2\vec{r}}{dt^2}=\frac{\vec{F}_{net}}{m}$$The goal is to solve this differential equation for $\vec{r}$ as a function of time, which is called the equation of motion. We often write time derivatives with a dot (since time derivatives are so common in physics) so Newton's second law looks like this.
$$\ddot{\vec{r}}=\frac{\vec{F}_{net}}{m}$$You have to integrate once to get velocity.
$$\vec{v}=\vec{v}_0+\int\frac{\vec{F}_{net}}{m}dt$$Then you have to integrate again to get $\vec{r}$ as a function of time, which is called the equation of motion.
For a constant net force this differential equation can be easily solved analytically. (An analytical solution is one where you integrate functions by hand, without a computer.) For a few other net force functions, such as the force by a spring on a particle, the differential equation can be solved analytically.
However, there are many possible forces in nature that give differential equations that can not be solved analytically. In this case, you must use a computer to integrate in small time steps ${\Delta t}$. After many small time steps, the differential equation leads to predictions of the particle's velocity and position. This is called a numerical solution.
In this notebook, you will learn how to numerically integrate Newton's second law to get velocity and how to integrate velocity to get position.
From Newton's second law, the velocity is
$$\vec{v}=\vec{v}_0+\int\frac{\vec{F}_{net}}{m}dt\ .$$For any time $t$, the velocity at $t+\Delta t$ will be
$$\vec{v}_{(t+\Delta t)}=\vec{v}_{t}+\frac{\vec{F}_{net}}{m}\Delta t$$Numerically integrating means starting at $t=0$ and repeating this calculation in small time steps $\Delta t$. In this way, you are summing the quantity $\frac{\vec{F}_{net}}{m}\Delta t$.
Starting with the definition of velocity $\vec{v}=\frac{d\vec{r}}{dt}$, then
$$d\vec{r}=\vec{v}dt$$and
$$\vec{r}= \vec{r}_0 + \int \vec{v}dt\, .$$We can solve this analytically if we know $\vec{v}(t)$ or we can solve it numerically by summing $\vec{v}\Delta t$ for many small time steps, $\Delta t$. The position at any time $t+\Delta t$ is
$$\vec{r}_{(t+\Delta t)} = \vec{r}_{(t)} + \vec{v}\Delta t\, .$$Note that $\vec{v}$ is not necessarily constant. So should you use $\vec{v}_t$ (the velocitiy at the beginning of the time interval) or $\vec{v}_{(t+\Delta t)}$ (the velocity at the end of the time interval) or perhaps an average of the two? A fairly accurate and simple method is called the Euler-Cromer method. In this case, you evaluate the velocity at the end of the time interval first and then use this velocity to find the position. Thus,
$$\vec{r}_{(t+\Delta t)} = \vec{r}_{(t)} + \vec{v}_{(t+\Delta t)}\Delta t\, .$$By repeating this calculation in a loop from $t=0$ to $t=t_f$, you are effectively integrating numerically.
To integrate Newton's second law to determine the position and velocity of a particle at all times, we must apply the following steps in a loop, using small time steps $\Delta t$:
Also you have to know the initial conditions:
These should be defined at the beginning of the loop.
Suppose that a 0.05 kg projectile is launched with an initial speed of 30 m/s at an angle of 50$^\circ$, and it lands at approximately the same height from which it was launched. Calculate the total time that it is in the air and the total horizontal distance traveled.
In [12]:
from __future__ import division, print_function
from ivisual import *
from math import *
In [14]:
scene=canvas(title="Projectile")
m=0.05 #kg
g=9.8 #N/kg
v0=30 #m/s
theta=50 #deg
theta_rad=50*pi/180
#initial conditions
r=vector(0,0,0)
v=v0*vector(cos(theta_rad),sin(theta_rad),0)
Fnet=vector(0,-m*g,0)
t=0
dt=0.01
projectile=sphere(pos=r, radius=2, color=color.red)
ground=box(pos=(0,0,0), size=(200,1,20), color=color.green)
while r.y>-0.1:
rate(100)
#3 steps: calculate force, update velocity, update position
Fnet=vector(0,-m*g,0)
v=v+Fnet/m*dt
r=r+v*dt
#updating the clock is a good idea in case you are graphing data
#or you need to run the while loop for a certain amount of time
t=t+dt
projectile.pos=r
print("Total time in the air =",t, " s")
print("Total horizontal distance traveled =", r.x, " m")
How would you modify the previous program in order to find the maximum height that the projectile traveled? Modify it now and print the maximum height traveled. (Hint: at the maximum height, $v_y=0$. However, the data point closest to this will have $|v_y|<$0.05 where 0.05 is a small value that you can adjust as necessary.)
In [ ]: